package club.janna.concurrency.example.singleton;

import club.janna.concurrency.annotation.ThreadSafe;

/**
 * 单例-静态内部类
 * 使用静态内部类实现单例
 * @Auther: guopanbo
 * @Date: 2018/8/1 21:49
 * @Description:
 */
@ThreadSafe
public class SingletonExample7 {

    private SingletonExample7() {}

    private static class SingletonHolder {
        private static SingletonExample7 instance = new SingletonExample7();
    }

    public static SingletonExample7 getInstance() {
        return SingletonHolder.instance;
    }



    public static void main(String[] args) {
        System.out.println(getInstance().hashCode());
        System.out.println(getInstance().hashCode());
    }
}
